import datetime
from common.mysqlUtil import  exc_sql2
from common.YmlUtil import YmlUtil
from RootPath import RootPath
import os

from dataGenerator.shenshui.contenPara import *
path = os.path.join(RootPath.getRootPath(), "Application.yml")
MySQLconf = YmlUtil().readYml(path,"mysql_test_243")


def device_pump_run_efficiency():
    print("=========ss====device_pump_run_efficiency========")
    # INSERT INTO `waterdb_ii`.`device_pump_run_efficiency`(`date_time`, `id`, `q`, `h`, `label_oper`, `label_power`, `label_output`, `label_runMode`, `efficiency`, `efficiency_label`) VALUES ('
    # 2020-12-02 23:59:00', '9', '73.059998', '35', 2, 0, 2, '1', 51.02, 'H2');
    h=OutletPressure-InletPressure
    sql1="INSERT INTO `waterdb_ii`.`device_pump_run_efficiency`(`date_time`, `id`, `q`, `h`, `label_oper`, `label_power`, `label_output`, `label_runMode`, `efficiency`, `efficiency_label`) VALUES ('"
    dateTime = ( datetime.datetime.now()).strftime("%Y-%m-%d %H:%M:%S")
    value1="', '9', '"
    value3="', 2, 0, 2, '1', 51.02, '"
    list =["H1","H2","L"]
    value2=random.choice(list)
    sql = sql1+dateTime+value1+str(InstantaneousFlow)+"', '"+str(h)+value3+value2+"');"
    print(sql)
    exc_sql2(sql,MySQLconf)


if __name__ == '__main__':
    device_pump_run_efficiency()